//
//  ViewController.m
//  富文本替换测试
//
//  Created by xukai on 2017/5/27.
//  Copyright © 2017年 xukai. All rights reserved.
//

#import "ViewController.h"

#import "MJExtension.h"
#import "CodeModel.h"

@interface ViewController ()
@property (weak, nonatomic) IBOutlet UILabel *testLab;

@property (nonatomic, strong) NSArray *datas;

@end

@implementation ViewController


-(NSArray *) datas
{
    if(!_datas)
    {
        NSString *filePath = [[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent:@"face.html"];
        NSString *json=[NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil];
        NSDictionary *dic = [self JSONObjectWithStr:json];
        
        _datas = [CodeModel mj_objectArrayWithKeyValuesArray:dic];
    }
    return _datas;
}

- (id)JSONObjectWithStr:(NSString *) str
{
    if(str == nil){
        return str;
    }
    NSError *err = nil;
    NSData *data = [str dataUsingEncoding:NSUTF8StringEncoding];
    id jsonValue = [NSJSONSerialization JSONObjectWithData:data
                                                   options:NSJSONReadingMutableContainers|NSJSONReadingMutableLeaves
                                                     error:&err];
    
    if(err)
        NSLog(@"%@", [err description]);
    return jsonValue;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    
   _testLab.text = @"我是{:boy-pick-nose:}几多搜集电视都死了;ds{:girl-shriek:}jjj";

    
}


@end
